/******************************************************************************
* 
* Announce: CSharpKit, Basic algorithms, components and definitions.
*           Copyright (C) ShenYongchen.
*           All rights reserved.
*   Author: 申永辰.郑州 (shenyczz@163.com)
*  WebSite: http://github.com/shenyczz/CSharpKit
*
* THIS CODE IS LICENSED UNDER THE MIT LICENSE (MIT).
* THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF 
* ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
* IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
* PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
* 
******************************************************************************/
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace CSharpKit.GeoApi.Geometries
{
    /// <summary>
    /// 射线
    /// </summary>
    public class Ray : LinearString, IPolyline
    {
        #region Constructors

        /// <summary>
        /// 默认构造函数
        /// </summary>
        public Ray() { }

        #endregion

        #region Properties

        /// <summary>
        /// 长度
        /// </summary>
        public Double Length
        {
            get { return computeLength(); }
        }

        // public Boolean IsClose

        #endregion

        #region Public Functions

        /// <summary>
        /// 使图形偏移指定的量
        /// </summary>
        /// <param name="dx">X坐标的偏移量</param>
        /// <param name="dy">Y坐标的偏移量</param>
        //public override void Offset(Double dx, Double dy)
        //{
        //    base.Offset(dx, dy);
        //}

        #endregion

        #region Private Functions

        /// <summary>
        /// 计算长度
        /// </summary>
        /// <returns></returns>
        private Double computeLength()
        {
            Double len = 0;

            int pointCount = this.Count;
            for (int i = 0; i < pointCount - 1; i++)
            {
                Point point1 = this[i + 0] as Point;
                Point point2 = this[i + 1] as Point;
                len += point1.Distance(point2);
            }

            return len;
        }

        #endregion

        //}}@@@
    }



}
